/**
 */
package autoSAR.impl;

import autoSAR.AutoSARPackage;
import autoSAR.Entity;
import autoSAR.Trigger;
import autoSAR.Variable;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Entity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link autoSAR.impl.EntityImpl#getName <em>Name</em>}</li>
 *   <li>{@link autoSAR.impl.EntityImpl#getTrigger <em>Trigger</em>}</li>
 *   <li>{@link autoSAR.impl.EntityImpl#getWriteVariable <em>Write Variable</em>}</li>
 *   <li>{@link autoSAR.impl.EntityImpl#getReadVariable <em>Read Variable</em>}</li>
 * </ul>
 *
 * @generated
 */
public class EntityImpl extends MinimalEObjectImpl.Container implements Entity {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getTrigger() <em>Trigger</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTrigger()
	 * @generated
	 * @ordered
	 */
	protected static final Trigger TRIGGER_EDEFAULT = Trigger.TIME;

	/**
	 * The cached value of the '{@link #getTrigger() <em>Trigger</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTrigger()
	 * @generated
	 * @ordered
	 */
	protected Trigger trigger = TRIGGER_EDEFAULT;

	/**
	 * The cached value of the '{@link #getWriteVariable() <em>Write Variable</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWriteVariable()
	 * @generated
	 * @ordered
	 */
	protected EList<Variable> writeVariable;

	/**
	 * The cached value of the '{@link #getReadVariable() <em>Read Variable</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReadVariable()
	 * @generated
	 * @ordered
	 */
	protected EList<Variable> readVariable;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EntityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return AutoSARPackage.Literals.ENTITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AutoSARPackage.ENTITY__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Trigger getTrigger() {
		return trigger;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTrigger(Trigger newTrigger) {
		Trigger oldTrigger = trigger;
		trigger = newTrigger == null ? TRIGGER_EDEFAULT : newTrigger;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AutoSARPackage.ENTITY__TRIGGER, oldTrigger, trigger));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Variable> getWriteVariable() {
		if (writeVariable == null) {
			writeVariable = new EObjectResolvingEList<Variable>(Variable.class, this,
					AutoSARPackage.ENTITY__WRITE_VARIABLE);
		}
		return writeVariable;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Variable> getReadVariable() {
		if (readVariable == null) {
			readVariable = new EObjectResolvingEList<Variable>(Variable.class, this,
					AutoSARPackage.ENTITY__READ_VARIABLE);
		}
		return readVariable;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case AutoSARPackage.ENTITY__NAME:
			return getName();
		case AutoSARPackage.ENTITY__TRIGGER:
			return getTrigger();
		case AutoSARPackage.ENTITY__WRITE_VARIABLE:
			return getWriteVariable();
		case AutoSARPackage.ENTITY__READ_VARIABLE:
			return getReadVariable();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case AutoSARPackage.ENTITY__NAME:
			setName((String) newValue);
			return;
		case AutoSARPackage.ENTITY__TRIGGER:
			setTrigger((Trigger) newValue);
			return;
		case AutoSARPackage.ENTITY__WRITE_VARIABLE:
			getWriteVariable().clear();
			getWriteVariable().addAll((Collection<? extends Variable>) newValue);
			return;
		case AutoSARPackage.ENTITY__READ_VARIABLE:
			getReadVariable().clear();
			getReadVariable().addAll((Collection<? extends Variable>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case AutoSARPackage.ENTITY__NAME:
			setName(NAME_EDEFAULT);
			return;
		case AutoSARPackage.ENTITY__TRIGGER:
			setTrigger(TRIGGER_EDEFAULT);
			return;
		case AutoSARPackage.ENTITY__WRITE_VARIABLE:
			getWriteVariable().clear();
			return;
		case AutoSARPackage.ENTITY__READ_VARIABLE:
			getReadVariable().clear();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case AutoSARPackage.ENTITY__NAME:
			return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		case AutoSARPackage.ENTITY__TRIGGER:
			return trigger != TRIGGER_EDEFAULT;
		case AutoSARPackage.ENTITY__WRITE_VARIABLE:
			return writeVariable != null && !writeVariable.isEmpty();
		case AutoSARPackage.ENTITY__READ_VARIABLE:
			return readVariable != null && !readVariable.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuilder result = new StringBuilder(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", trigger: ");
		result.append(trigger);
		result.append(')');
		return result.toString();
	}

} //EntityImpl
